*!* First we create an instance of the form class defined below *!* (This is the form that allows the user to pick a start and end date) oFrmDate = CREATEOBJECT("frmdatepick") *!* Now, we show it. Since the form is modal, execution suspends *!* until the form is released (and the user has selected a valid *!* start and end date) oFrmDate.Show *!* Note that there is no error checking here because the form is *!* designed so that the user cannot exit with invalid data returned. *!* The form has put the user's selection into two public variables *!* (dStart_date and dEnd_date), so now we can just release the form *!* and return back to the report. RELEASE oFrmDate RETURN PUBLIC ofrmdatepick ofrmdatepick=CREATEOBJECT("frmdatepick") ofrmdatepick.Show() RETURN ************************************************** *-- Form: frmdatepick *-- ParentClass: form *-- BaseClass: form * DEFINE CLASS frmdatepick AS form Height = 101 Width = 335 DoCreate = .T. AutoCenter = .T. BorderStyle = 2 Caption = "Date Range to Print" Closable = .F. MaxButton = .F. MinButton = .F. WindowType = 1 Name = "frmdatepick" ADD OBJECT label1 AS label WITH ; AutoSize = .T., ; FontName = "MS Sans Serif", ; FontSize = 8, ; Caption = "Select dates to print a range of invoices.", ; Height = 15, ; Left = 10, ; Top = 10, ; Width = 196, ; TabIndex = 1, ; Name = "Label1" ADD OBJECT label2 AS label WITH ; AutoSize = .T., ; FontName = "MS Sans Serif", ; FontSize = 8, ; Caption = "\ nToYear) OR (nFromYear = nToYear AND ; nFromMonth > nToMonth) THEN MESSAGEBOX(FROM_GREATER_TO_LOC) THISFORM.cboFromYear.SetFocus RETURN ENDIF *!* For the end date, we need to figure out the last day of the month *!* that was selected. *!* (Note that the one flaw in this CASE statement is that it doesn't *!* take into account leap year.) DO CASE CASE nToMonth = 2 nEndDay = 28 CASE INLIST(nToMonth,4,6,9,11) nEndDay = 30 OTHERWISE nEndDay = 31 ENDCASE *!* Finally, we can set up our start and end date public variables dStart_Date = DATE(nFromYear,nFromMonth,1) dEnd_Date = DATE(nToYear,nToMonth,nEndDay) THISFORM.Release ENDPROC ENDDEFINE * *-- EndDefine: frmdatepick **************************************************